package Thread_;

import java.util.Scanner;

public class Thread15 {
    //线程可见性引起的线程安全问题
    private static volatile int flag=0;
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            while(flag==0){
            }
            System.out.println("t1线程结束！");
        });
        t1.start();
        Scanner scan = new Scanner(System.in);
        System.out.println("将flag修改为1：");
        flag=scan.nextInt();
    }
}
